<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>图书借阅系统 - 添加图书</title>
    <!-- 引入 Google Fonts 以使用更现代的字体 -->
    <link href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap" rel="stylesheet">
    <style>
        body {
            font-family: 'Poppins', sans-serif;
            margin: 0;
            padding: 0;
            background-color: #f4f4f9;
            color: #333;
            background-image: url('https://images.unsplash.com/photo-1507842217343-583bb7270b66');
            background-size: cover;
            background-position: center;
            background-repeat: no-repeat;
            backdrop-filter: blur(5px);
            display: flex;
            flex-direction: column;
            align-items: center;
            min-height: 100vh;
        }

        nav {
            background-color: rgba(44, 62, 80, 0.9);
            overflow: hidden;
            position: fixed;
            top: 0;
            width: 100%;
            z-index: 1000;
            box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
            transition: background-color 0.3s ease;
        }

        nav ul {
            list-style-type: none;
            margin: 0;
            padding: 0;
            display: flex;
            justify-content: center;
        }

        nav ul li {
            margin: 0 10px;
        }

        nav ul li a {
            display: block;
            color: white;
            text-align: center;
            padding: 16px 20px;
            text-decoration: none;
            transition: background-color 0.3s ease, transform 0.3s ease;
            font-size: 16px;
        }

        nav ul li a:hover {
            background-color: #34495e;
            transform: scale(1.05);
        }

        .container {
            padding: 50px 40px 40px 40px;
            max-width: 600px;
            width: 90%;
            background-color: rgba(255, 255, 255, 0.9);
            border-radius: 15px;
            box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
            margin-top: 50px;
            animation: fadeIn 0.5s ease;
            transition: box-shadow 0.3s ease;
        }

        .container:hover {
            box-shadow: 0 15px 30px rgba(0, 0, 0, 0.3);
        }

        @keyframes fadeIn {
            from {
                opacity: 0;
                transform: translateY(-20px);
            }
            to {
                opacity: 1;
                transform: translateY(0);
            }
        }

        h1 {
            font-size: 3em;
            color: #2c3e50;
            text-align: center;
            margin-top: 20px;
            margin-bottom: 35px;
            text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
            background: -webkit-linear-gradient(45deg, #2c3e50, #007BFF);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
        }

        form label {
            display: block;
            margin-bottom: 5px;
            font-weight: 500;
        }

        form input {
            width: 100%;
            padding: 10px;
            margin-bottom: 20px;
            border: 1px solid #ccc;
            border-radius: 8px;
            font-size: 16px;
            transition: border-color 0.3s ease, box-shadow 0.3s ease;
            background-color: rgba(255, 255, 255, 0.8);
        }

        form input:focus {
            border-color: #007BFF;
            outline: none;
            box-shadow: 0 0 5px rgba(0, 123, 255, 0.5);
        }

        form button {
            padding: 15px 30px;
            background-color: #007BFF;
            color: white;
            border: none;
            border-radius: 8px;
            cursor: pointer;
            transition: background-color 0.3s ease, transform 0.3s ease;
            font-size: 16px;
            font-weight: 500;
            box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
        }

        form button:hover {
            background-color: #0056b3;
            transform: scale(1.05);
        }
    </style>
    <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
</head>

<body>
<nav>
    <ul>
        <li><a href="http://localhost:8888/lib/allbook">图书列表</a></li>
        <li><a href="http://localhost:8888/lib/allborrow">借阅记录</a></li>
        <li><a href="http://localhost:8888/lib/alluser">用户信息</a></li>
        <li><a href="http://localhost:8888/lib/addBook">添加图书</a></li>
        <li><a href="http://localhost:8888/lib/deleteBook">删除图书</a></li>
        <li><a href="http://localhost:8888/api/outLogin">退出</a></li>
    </ul>
</nav>
<div class="container">
    <h1>添加图书</h1>
    <form id="add-book-form">
        <label for="book-name">书名:</label>
        <input type="text" id="book-name" required>
        <label for="author">作者:</label>
        <input type="text" id="author" required>
        <label for="quantity">数量:</label>
        <input type="number" id="quantity" required>
        <button type="submit">添加</button>
    </form>
</div>
<script>
    $(document).ready(function () {
        $('#add-book-form').on('submit', function (e) {
            e.preventDefault();
            const bookName = $('#book-name').val();
            const author = $('#author').val();
            const nums = $('#quantity').val();
            $.post(`http://localhost:8888/manager/addBook/${bookName}/${author}/${nums}`,function(data){
                    alert(data.msg);
                    window.location.reload();
                })
            })
    })
</script>
</body>

</html>
    